home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / sound / mtc / mtc.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-09-17  |  20.7 KB  |  630 lines

  1. VERSION 2.00
  2. Begin Form MTCForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "SMPTE : 25 Fr/s"
  6.    ClientHeight    =   2550
  7.    ClientLeft      =   3030
  8.    ClientTop       =   2775
  9.    ClientWidth     =   2985
  10.    ControlBox      =   0   'False
  11.    Height          =   3240
  12.    Icon            =   MTC.FRX:0000
  13.    KeyPreview      =   -1  'True
  14.    Left            =   2970
  15.    LinkTopic       =   "Form1"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   2550
  19.    ScaleWidth      =   2985
  20.    Top             =   2145
  21.    Width           =   3105
  22.    Begin Timer Timer1 
  23.       Interval        =   500
  24.       Left            =   870
  25.       Top             =   2610
  26.    End
  27.    Begin SSPanel Z 
  28.       BackColor       =   &H00C0C0C0&
  29.       BevelInner      =   2  'Raised
  30.       BorderWidth     =   1
  31.       Font3D          =   0  'None
  32.       ForeColor       =   &H00FF0000&
  33.       Height          =   2235
  34.       Index           =   1
  35.       Left            =   180
  36.       TabIndex        =   14
  37.       Top             =   180
  38.       Width           =   2655
  39.       Begin SSPanel Z 
  40.          BackColor       =   &H00C0C0C0&
  41.          BevelOuter      =   0  'None
  42.          BorderWidth     =   1
  43.          Caption         =   "Out"
  44.          Font3D          =   3  'Inset w/light shading
  45.          ForeColor       =   &H00FF0000&
  46.          Height          =   195
  47.          Index           =   2
  48.          Left            =   2160
  49.          TabIndex        =   21
  50.          Top             =   60
  51.          Width           =   375
  52.       End
  53.       Begin SSPanel Z 
  54.          BackColor       =   &H00C0C0C0&
  55.          BevelOuter      =   0  'None
  56.          BorderWidth     =   1
  57.          Caption         =   "In"
  58.          Font3D          =   3  'Inset w/light shading
  59.          ForeColor       =   &H00FF0000&
  60.          Height          =   195
  61.          Index           =   0
  62.          Left            =   150
  63.          TabIndex        =   20
  64.          Top             =   90
  65.          Width           =   315
  66.       End
  67.       Begin SSPanel OutShow 
  68.          BackColor       =   &H00C0C0C0&
  69.          BevelInner      =   1  'Inset
  70.          BevelOuter      =   1  'Inset
  71.          BorderWidth     =   1
  72.          Caption         =   "u"
  73.          Font3D          =   0  'None
  74.          FontBold        =   -1  'True
  75.          FontItalic      =   0   'False
  76.          FontName        =   "Wingdings"
  77.          FontSize        =   8.25
  78.          FontStrikethru  =   0   'False
  79.          FontUnderline   =   0   'False
  80.          ForeColor       =   &H00FF0000&
  81.          Height          =   255
  82.          Left            =   2220
  83.          TabIndex        =   19
  84.          Top             =   270
  85.          Width           =   255
  86.       End
  87.       Begin SSPanel InShow 
  88.          BackColor       =   &H00C0C0C0&
  89.          BevelInner      =   1  'Inset
  90.          BevelOuter      =   1  'Inset
  91.          BorderWidth     =   1
  92.          Caption         =   "u"
  93.          Font3D          =   0  'None
  94.          FontBold        =   -1  'True
  95.          FontItalic      =   0   'False
  96.          FontName        =   "Wingdings"
  97.          FontSize        =   8.25
  98.          FontStrikethru  =   0   'False
  99.          FontUnderline   =   0   'False
  100.          ForeColor       =   &H00FF0000&
  101.          Height          =   255
  102.          Left            =   180
  103.          TabIndex        =   18
  104.          Top             =   270
  105.          Width           =   255
  106.       End
  107.       Begin SSPanel Z 
  108.          BackColor       =   &H00C0C0C0&
  109.          BevelInner      =   2  'Raised
  110.          BevelOuter      =   0  'None
  111.          BevelWidth      =   2
  112.          BorderWidth     =   0
  113.          Font3D          =   0  'None
  114.          Height          =   525
  115.          Index           =   5
  116.          Left            =   570
  117.          TabIndex        =   0
  118.          Top             =   240
  119.          Width           =   1500
  120.          Begin SSPanel Z 
  121.             BackColor       =   &H00C0C0C0&
  122.             BevelInner      =   1  'Inset
  123.             BevelOuter      =   0  'None
  124.             BevelWidth      =   3
  125.             BorderWidth     =   0
  126.             Font3D          =   0  'None
  127.             Height          =   330
  128.             Index           =   4
  129.             Left            =   90
  130.             TabIndex        =   1
  131.             Top             =   90
  132.             Width           =   1335
  133.             Begin Label ZZ 
  134.                Alignment       =   2  'Center
  135.                BackColor       =   &H00000000&
  136.                Caption         =   ":"
  137.                FontBold        =   -1  'True
  138.                FontItalic      =   0   'False
  139.                FontName        =   "MS Sans Serif"
  140.                FontSize        =   9.75
  141.                FontStrikethru  =   0   'False
  142.                FontUnderline   =   0   'False
  143.                ForeColor       =   &H0000FFFF&
  144.                Height          =   240
  145.                Index           =   2
  146.                Left            =   945
  147.                TabIndex        =   2
  148.                Top             =   30
  149.                Width           =   105
  150.             End
  151.             Begin Label ZZ 
  152.                Alignment       =   2  'Center
  153.                BackColor       =   &H00000000&
  154.                Caption         =   ":"
  155.                FontBold        =   -1  'True
  156.                FontItalic      =   0   'False
  157.                FontName        =   "MS Sans Serif"
  158.                FontSize        =   9.75
  159.                FontStrikethru  =   0   'False
  160.                FontUnderline   =   0   'False
  161.                ForeColor       =   &H0000FFFF&
  162.                Height          =   240
  163.                Index           =   1
  164.                Left            =   610
  165.                TabIndex        =   3
  166.                Top             =   30
  167.                Width           =   105
  168.             End
  169.             Begin Label ZZ 
  170.                Alignment       =   2  'Center
  171.                BackColor       =   &H00000000&
  172.                Caption         =   ":"
  173.                FontBold        =   -1  'True
  174.                FontItalic      =   0   'False
  175.                FontName        =   "MS Sans Serif"
  176.                FontSize        =   9.75
  177.                FontStrikethru  =   0   'False
  178.                FontUnderline   =   0   'False
  179.                ForeColor       =   &H0000FFFF&
  180.                Height          =   240
  181.                Index           =   0
  182.                Left            =   300
  183.                TabIndex        =   4
  184.                Top             =   30
  185.                Width           =   90
  186.             End
  187.             Begin Label txtFrames 
  188.                Alignment       =   1  'Right Justify
  189.                BackColor       =   &H00000000&
  190.                Caption         =   "00"
  191.                FontBold        =   -1  'True
  192.                FontItalic      =   0   'False
  193.                FontName        =   "MS Sans Serif"
  194.                FontSize        =   9.75
  195.                FontStrikethru  =   0   'False
  196.                FontUnderline   =   0   'False
  197.                ForeColor       =   &H0000FFFF&
  198.                Height          =   240
  199.                Left            =   1020
  200.                TabIndex        =   5
  201.                Top             =   30
  202.                Width           =   270
  203.             End
  204.             Begin Label txtSeconds 
  205.                Alignment       =   2  'Center
  206.                BackColor       =   &H00000000&
  207.                Caption         =   "00"
  208.                FontBold        =   -1  'True
  209.                FontItalic      =   0   'False
  210.                FontName        =   "MS Sans Serif"
  211.                FontSize        =   9.75
  212.                FontStrikethru  =   0   'False
  213.                FontUnderline   =   0   'False
  214.                ForeColor       =   &H0000FFFF&
  215.                Height          =   240
  216.                Left            =   720
  217.                TabIndex        =   6
  218.                Top             =   30
  219.                Width           =   225
  220.             End
  221.             Begin Label txtMinutes 
  222.                Alignment       =   2  'Center
  223.                BackColor       =   &H00000000&
  224.                Caption         =   "00"
  225.                FontBold        =   -1  'True
  226.                FontItalic      =   0   'False
  227.                FontName        =   "MS Sans Serif"
  228.                FontSize        =   9.75
  229.                FontStrikethru  =   0   'False
  230.                FontUnderline   =   0   'False
  231.                ForeColor       =   &H0000FFFF&
  232.                Height          =   240
  233.                Left            =   390
  234.                TabIndex        =   7
  235.                Top             =   30
  236.                Width           =   225
  237.             End
  238.             Begin Label txtHours 
  239.                Alignment       =   1  'Right Justify
  240.                BackColor       =   &H00000000&
  241.                Caption         =   "00"
  242.                FontBold        =   -1  'True
  243.                FontItalic      =   0   'False
  244.                FontName        =   "MS Sans Serif"
  245.                FontSize        =   9.75
  246.                FontStrikethru  =   0   'False
  247.                FontUnderline   =   0   'False
  248.                ForeColor       =   &H0000FFFF&
  249.                Height          =   240
  250.                Left            =   52
  251.                TabIndex        =   8
  252.                Top             =   30
  253.                Width           =   255
  254.             End
  255.          End
  256.       End
  257.       Begin SSPanel BotonsBox 
  258.          AutoSize        =   3  'AutoSize Child To Panel
  259.          BackColor       =   &H00C0C0C0&
  260.          BevelInner      =   2  'Raised
  261.          BevelWidth      =   2
  262.          BorderWidth     =   2
  263.          Font3D          =   0  'None
  264.          ForeColor       =   &H00FF0000&
  265.          Height          =   675
  266.          Left            =   210
  267.          TabIndex        =   9
  268.          Top             =   1410
  269.          Width           =   2235
  270.          Begin SSCommand cmdRewind 
  271.             BevelWidth      =   0
  272.             Font3D          =   0  'None
  273.             Height          =   495
  274.             Left            =   90
  275.             Outline         =   0   'False
  276.             Picture         =   MTC.FRX:0302
  277.             TabIndex        =   10
  278.             Top             =   90
  279.             Width           =   495
  280.          End
  281.          Begin SSCommand cmdForward 
  282.             BevelWidth      =   0
  283.             Font3D          =   0  'None
  284.             Height          =   495
  285.             Left            =   1620
  286.             Outline         =   0   'False
  287.             Picture         =   MTC.FRX:0604
  288.             TabIndex        =   11
  289.             Top             =   90
  290.             Width           =   495
  291.          End
  292.          Begin SSCommand cmdPlay 
  293.             BevelWidth      =   0
  294.             Font3D          =   0  'None
  295.             Height          =   495
  296.             Left            =   600
  297.             Outline         =   0   'False
  298.             Picture         =   MTC.FRX:0906
  299.             TabIndex        =   12
  300.             Top             =   90
  301.             Width           =   495
  302.          End
  303.          Begin SSCommand cmdStop 
  304.             BevelWidth      =   0
  305.             Font3D          =   0  'None
  306.             Height          =   495
  307.             Left            =   1110
  308.             Outline         =   0   'False
  309.             Picture         =   MTC.FRX:0C08
  310.             TabIndex        =   13
  311.             Top             =   90
  312.             Width           =   495
  313.          End
  314.       End
  315.       Begin SSPanel Z 
  316.          BackColor       =   &H00C0C0C0&
  317.          BevelInner      =   2  'Raised
  318.          BevelOuter      =   1  'Inset
  319.          BorderWidth     =   1
  320.          Font3D          =   0  'None
  321.          ForeColor       =   &H00FF0000&
  322.          Height          =   405
  323.          Index           =   10
  324.          Left            =   210
  325.          TabIndex        =   15
  326.          Top             =   870
  327.          Width           =   2235
  328.          Begin SSOption optWrite 
  329.             Caption         =   "Write"
  330.             Font3D          =   3  'Inset w/light shading
  331.             ForeColor       =   &H00FF0000&
  332.             Height          =   210
  333.             Left            =   180
  334.             TabIndex        =   17
  335.             Top             =   100
  336.             Value           =   -1  'True
  337.             Width           =   705
  338.          End
  339.          Begin SSOption optRead 
  340.             Caption         =   "Read"
  341.             Font3D          =   3  'Inset w/light shading
  342.             ForeColor       =   &H00FF0000&
  343.             Height          =   195
  344.             Left            =   1170
  345.             TabIndex        =   16
  346.             TabStop         =   0   'False
  347.             Top             =   100
  348.             Width           =   735
  349.          End
  350.       End
  351.    End
  352.    Begin MsgHook MidiHook 
  353.       Left            =   390
  354.       Top             =   2610
  355.    End
  356.    Begin Menu mnuSetup 
  357.       Caption         =   "&Setup"
  358.       Begin Menu SetupMidi 
  359.          Caption         =   "&Midi Devices..."
  360.       End
  361.       Begin Menu SetupFrameMode 
  362.          Caption         =   "&Frame Mode..."
  363.       End
  364.    End
  365.    Begin Menu mnuOptions 
  366.       Caption         =   "&Options"
  367.       Begin Menu OptionsMidiThru 
  368.          Caption         =   "&Midi Thru"
  369.       End
  370.       Begin Menu OptionsOnlyMTC 
  371.          Caption         =   "&Only MTC"
  372.          Checked         =   -1  'True
  373.       End
  374.    End
  375.    Begin Menu mnuExit 
  376.       Caption         =   "&Exit"
  377.       Begin Menu ExitYes 
  378.          Caption         =   "&Yes"
  379.       End
  380.       Begin Menu ExitNo 
  381.          Caption         =   "&No"
  382.       End
  383.    End
  384. Option Explicit
  385. Sub cmdForward_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  386.     Dim p As Integer
  387.     flgDown = True
  388.     p = True
  389.     Do While flgDown = True
  390.         Select Case Shift
  391.             Case 0:
  392.                 fff = fff + 1
  393.                 disp_fff = disp_fff + 1
  394.             Case ALT_MASK:
  395.                 sss = sss + 1
  396.                 disp_sss = disp_sss + 1
  397.             Case CTRL_MASK:
  398.                 mmm = mmm + 1
  399.                 disp_mmm = disp_mmm + 1
  400.             Case SHIFT_MASK:
  401.                 hhh = hhh + 1
  402.                 disp_hhh = disp_hhh + 1
  403.         End Select
  404.         Display_Adjust
  405.         SMPTE_Adjust
  406.         DoEvents
  407.         If p = True Then  'Primer click
  408.             Wait (300)   'el que sigui (s'ha de graduar)
  409.             p = False
  410.         Else                   'aguanta
  411.             Wait (30)     'tamb
  412.  s'ha de graduar
  413.         End If
  414.         DoEvents            'per llegir MouseUp que fa flgDown=False
  415.     Loop
  416. End Sub
  417. Sub cmdForward_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  418.     flgDown = False
  419. End Sub
  420. Sub cmdPlay_Click ()
  421.     Dim st As String
  422.     Dim CurrentTime As Long, OldTime As Long
  423.     If disp_hhh >= 24 Or disp_mmm >= 60 Or disp_sss >= 60 Or disp_fff >= Frame_Mode Then
  424.         Dlg_Alert "SMPTE incorrect!"
  425.         Exit Sub
  426.     End If
  427.     MTC_Write
  428. End Sub
  429. Sub cmdRewind_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  430.     Dim p As Integer
  431.     flgDown = True
  432.     p = True
  433.     Do While flgDown = True
  434.         Select Case Shift
  435.             Case 0:
  436.                 fff = fff - 1
  437.                 disp_fff = disp_fff - 1
  438.             Case ALT_MASK:
  439.                 sss = sss - 1
  440.                 disp_sss = disp_sss - 1
  441.             Case CTRL_MASK:
  442.                 mmm = mmm - 1
  443.                 disp_mmm = disp_mmm - 1
  444.             Case SHIFT_MASK:
  445.                 hhh = hhh - 1
  446.                 disp_hhh = disp_hhh - 1
  447.         End Select
  448.         Display_Adjust
  449.         SMPTE_Adjust
  450.         DoEvents
  451.         If p = True Then  'Primer click
  452.             Wait (300)   'el que sigui (s'ha de graduar)
  453.             p = False
  454.         Else                   'aguanta
  455.             Wait (30)     'tamb
  456.  s'ha de graduar
  457.         End If
  458.         DoEvents            'per llegir MouseUp que fa flgDown=False
  459.     Loop
  460. End Sub
  461. Sub cmdRewind_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  462.     flgDown = False
  463. End Sub
  464. Sub cmdStop_Click ()
  465.     flgStop = True
  466. End Sub
  467. Sub ExitYes_Click ()
  468.     MidiOut_Close
  469.     MidiIn_Close
  470.     If NumErrors <> 0 Then
  471.         Dlg_Alert CStr(NumErrors) & " MIDI Messages Lost!"
  472.     End If
  473.     End
  474. End Sub
  475. Sub Form_Activate ()
  476.     Dim msg As Long
  477.     Do
  478.         msg = MidiIn_Read()    'Empty InBuffer
  479.         DoEvents
  480.     Loop
  481. End Sub
  482. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  483.     Dim h As String, m As String, s As String, f As String
  484.     Dim i As Integer
  485.     If KeyCode = KEY_ESCAPE Then
  486.         txtHours = "00"
  487.         txtMinutes = "00"
  488.         txtSeconds = "00"
  489.         txtFrames = "00"
  490.     ElseIf IsNumber(KeyCode) = True Then
  491.         h = txtHours.Caption
  492.         m = txtMinutes.Caption
  493.         s = txtSeconds.Caption
  494.         f = txtFrames.Caption
  495.         Mid$(h, 1, 1) = Mid$(h, 2, 1)'00 00 00 00
  496.         Mid$(h, 2, 1) = Mid$(m, 1, 1)
  497.         Mid$(m, 1, 1) = Mid$(m, 2, 1)
  498.         Mid$(m, 2, 1) = Mid$(s, 1, 1)
  499.         Mid$(s, 1, 1) = Mid$(s, 2, 1)
  500.         Mid$(s, 2, 1) = Mid$(f, 1, 1)
  501.         Mid$(f, 1, 1) = Mid$(f, 2, 1)
  502.         Mid$(f, 2, 1) = CStr(KeyToNumber(KeyCode))
  503.         
  504.         txtHours.Caption = h
  505.         disp_hhh = Val(h)
  506.         txtMinutes.Caption = m
  507.         disp_mmm = Val(m)
  508.         txtSeconds.Caption = s
  509.         disp_sss = Val(s)
  510.         txtFrames.Caption = f
  511.         disp_fff = Val(f)
  512.     End If
  513.     KeyCode = 0
  514. End Sub
  515. Sub Form_Load ()
  516.     Dim nDevices    As Integer
  517.     Dim i           As Integer
  518.     Dim InCaps      As MidiInCaps
  519.     Dim OutCaps     As MidiOutCaps
  520.     Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
  521.     nDevices = midiInGetNumDevs()
  522.     If nDevices = 0 Then
  523.         Dlg_Alert "No Midi In Device!"
  524.     Else
  525.         For i = 0 To nDevices - 1
  526.             ret = midiInGetDevCaps(i, InCaps, Len(InCaps))
  527.             If ret <> 0 Then
  528.                 Alerta_MidiError (ret)
  529.                 Exit For
  530.             End If
  531.             MidiForm.InList.List(i) = InCaps.szPname
  532.         Next i
  533.     End If
  534.     nDevices = midiOutGetNumDevs()
  535.     If nDevices = 0 Then
  536.         Dlg_Alert "No Midi Out Device!"
  537.     Else
  538.         MidiForm.OutList.List(0) = "MS MIDI Mapper"   'Midi Mapper=possible MIDI OUT
  539.         For i = 0 To nDevices - 1
  540.             ret = midiOutGetDevCaps(i, OutCaps, Len(OutCaps))
  541.             If ret <> 0 Then
  542.                 Alerta_MidiError (ret)
  543.                 Exit For
  544.             End If
  545.             MidiForm.OutList.List(i + 1) = OutCaps.szPname
  546.         Next i
  547.     End If
  548.     Reset_BufferIn
  549.     hMidiIn = NO_HANDLE
  550.     hMidiOut = NO_HANDLE
  551.     TC_Type = 1
  552.     Frame_Mode = 25
  553.     Ms_per_QF = 10
  554.     QF_Counter = 0
  555.     MTC_Time = 0
  556.     NumErrors = 0
  557.     flgChangeIt = True
  558.     hhh = 0
  559.     mmm = 0
  560.     sss = 0
  561.     fff = 0
  562.     disp_hhh = 0
  563.     disp_mmm = 0
  564.     disp_sss = 0
  565.     disp_fff = 0
  566.     OutShow.Caption = ""
  567.     InShow.Caption = ""
  568.     MidiForm.Show 1
  569. End Sub
  570. Sub MidiHook_Message (msg As Integer, wParam As Integer, lParam As Long, action As Integer, result As Long)
  571.     If OptionsOnlyMTC.Checked = True Then
  572.         If (lParam And &HFF) <> &HF1 Then Exit Sub   'Accept only MTC messages
  573.     End If
  574.     If OptionsMidiThru.Checked = True Then
  575.         If hMidiOut <> NO_HANDLE Then
  576.             ret = midiOutShortMsg(hMidiOut, lParam)
  577.             OutShow.Caption = "u"
  578.         End If
  579.     End If
  580.     If BuffCounter = BUFFSIZE Then
  581.         NumErrors = NumErrors + 1&
  582.         Exit Sub
  583.     End If
  584.     While flgChangeIt = False
  585.         DoEvents
  586.     Wend
  587.     flgChangeIt = False
  588.     InBuffer(WriteIndex) = lParam
  589.     WriteIndex = WriteIndex + 1
  590.     If WriteIndex = BUFFSIZE Then WriteIndex = 0
  591.     BuffCounter = BuffCounter + 1
  592.     flgChangeIt = True
  593.     InShow.Caption = "u"
  594. End Sub
  595. Sub OptionsMidiThru_Click ()
  596.     OptionsMidiThru.Checked = Not OptionsMidiThru.Checked
  597. End Sub
  598. Sub OptionsOnlyMTC_Click ()
  599.     OptionsOnlyMTC.Checked = Not OptionsOnlyMTC.Checked
  600. End Sub
  601. Sub optRead_Click (Value As Integer)
  602.     If Value = True Then
  603.         BotonsBox.Visible = False
  604.         MTC_Read
  605.     Else
  606.         BotonsBox.Visible = True
  607.         flgReadStop = True
  608.     End If
  609. End Sub
  610. Sub optWrite_Click (Value As Integer)
  611.     If Value = True Then
  612.         BotonsBox.Visible = True
  613.         flgReadStop = True
  614.         Display_Adjust
  615.     Else
  616.         BotonsBox.Visible = False
  617.         flgReadStop = False
  618.     End If
  619. End Sub
  620. Sub SetupFrameMode_Click ()
  621.     FrameForm.Show 1
  622. End Sub
  623. Sub SetupMidi_Click ()
  624.     MidiForm.Show 1
  625. End Sub
  626. Sub Timer1_Timer ()
  627.     OutShow.Caption = ""
  628.     InShow.Caption = ""
  629. End Sub
  630.